package com.yunji.framework_template.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yunji.framework_template.biz.service.UserFellowersService;
import com.yunji.framework_template.common.web.Page;
import com.yunji.framework_template.common.web.Result;
import com.yunji.framework_template.orm.persistence.model.UserFellowers;

/**
 * Created by fenglibin on 2018/11/26.
 */
@Controller
@RequestMapping("/userFellowers/")
public class UserFellowersController {

    @Autowired
    UserFellowersService userFellowersService;

    @RequestMapping("selectAll")
    @ResponseBody
    public Result<List<UserFellowers>> selectAll() {
        return Result.success(userFellowersService.selectAll());
    }

    @RequestMapping("select")
    @ResponseBody
    public Result<UserFellowers> selectByPrimaryKey(Integer id) {
        return Result.success(userFellowersService.selectByPrimaryKey(id));
    }

    @RequestMapping("selectByCondition")
    @ResponseBody
    public Result<List<UserFellowers>> selectByCondition(UserFellowers record) {
        return Result.success(userFellowersService.selectByCondition(record));
    }

    @RequestMapping("count")
    @ResponseBody
    public Result<Integer> count(UserFellowers record) {
        return Result.success(userFellowersService.count(record));
    }

    @RequestMapping("insert")
    @ResponseBody
    public Result<Integer> insertSelective(UserFellowers record) {
        return Result.success(userFellowersService.insertSelective(record));
    }

    @RequestMapping("update")
    @ResponseBody
    public Result<Integer> updateByPrimaryKeySelective(UserFellowers record) {
        return Result.success(userFellowersService.updateByPrimaryKeySelective(record));
    }

    @RequestMapping("selectByPage")
    @ResponseBody
    public Result<Page<List<UserFellowers>>> selectByPage(Page<UserFellowers> page) {
        List<UserFellowers> list = null;
        page = page.sequentialDisplayCalculate(userFellowersService.count(page.getObj()));
        if (page.getTotalCount() > 0) {
            list = userFellowersService.selectByPage(page);
        }
        Page<List<UserFellowers>> result = new Page<List<UserFellowers>>(page, list);
        return Result.success(result);
    }

    @RequestMapping("deleteByCondition1")
    @ResponseBody
    public Result<Integer> deleteByCondition(UserFellowers record) {
        return Result.success(userFellowersService.deleteByCondition(record));
    }

    @RequestMapping("delete1")
    @ResponseBody
    public Result<Integer> deleteByPrimaryKey(Integer id) {
        return Result.success(userFellowersService.deleteByPrimaryKey(id));
    }

}
